package test;

import jdk.swing.interop.SwingInterOpUtils;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class MapWork {
    private static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
        HashMap<Integer, String> hashMap = new HashMap();
        hashMap.put(1, "Amy");
        hashMap.put(2, "Joe");
        hashMap.put(3, "Tom");
        hashMap.put(4, "Susan");
        Set keyset = hashMap.keySet();
        for (Object key : keyset) {
            System.out.println(key + ":" + hashMap.get(key));
        }
        System.out.println("请输入一个人名");
        hashMap.put(5, scan.next());
        hashMap.remove(4);
        hashMap.replace(3, "Tommy");
        Set keyset2 = hashMap.keySet();
        for (Object key : keyset2) {
            System.out.println(key + ":" + hashMap.get(key));
        }

    }


}
